package com.demo.controller;

import com.demo.entity.Course;
import com.demo.service.CourseServiceV1;
import com.demo.service.CourseServiceV2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by IntelliJ IDEA.
 * User: bj910
 * Date:2023-08-07
 * Time: 23:12
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/ds2")
public class CourseControllerV2 {

    @Autowired
    CourseServiceV2 courseService;

    @ResponseBody
    @RequestMapping("/queryCourse")
    public Object queryCourse(){
        return courseService.selectCourse();
    }

    @ResponseBody
    @RequestMapping("/createCourse1")
    public Object createCourse1( Course course){
        //没有事务控制的插入
        courseService.createCourse1(course);
        return "insert success";
    }

    @ResponseBody
    @RequestMapping("/createCourse2")
    public Object createCourse2( Course course){
        //有事务控制的插入
        courseService.createCourse2(course);
        return "insert success";
    }
}
